# 99个数字的全排列，用递归实现,打印出所有排列结果，不占用内存空间
def permute(nums):
    if len(nums) == 1:
        return [nums]
    else:
        result = []
        for i in range(len(nums)):
            # 固定第一个元素
            fixed = [nums[i]]
            # 递归处理剩余元素
            rest = nums[:i] + nums[i + 1 :]
            for p in permute(rest):
                result.append(fixed + p)
        return result


# 调用函数
nums = [i for i in range(1, 11)]
result = permute(nums)
for p in result:
    print(p)

import asyncio